package yunquan.wang.modules.base.web;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import yunquan.wang.base.web.WebConstants;
import yunquan.wang.modules.base.entity.DynamicReport;
import yunquan.wang.modules.base.entity.GroupType;
import yunquan.wang.modules.base.service.DynamicReportService;
@Controller
@RequestMapping("/core/dynamicreport")
public class DynamicReportController {
	@Resource
private	DynamicReportService dynamicReportService;
	
	@RequestMapping(value = "/input.do")
	public ModelAndView input(String id) {
		ModelAndView mv = new ModelAndView();
		if (StringUtils.isNotBlank(id)) {
			mv.addObject(WebConstants.ATTRIBUTE_ENTITY,
					dynamicReportService.get(id));
		} else {
			mv.addObject(WebConstants.ATTRIBUTE_ENTITY, new GroupType());
		}
		return mv;
	}
	/**
	 * Save the SQL
	 * @param entity
	 * @return
	 */
	public ModelAndView saveSql(DynamicReport entity)
	{
		ModelAndView mv = new ModelAndView();
		dynamicReportService.save(entity);
		return mv;
	}
	
	public ModelAndView inputColumn(String id)
	{
		ModelAndView mv = new ModelAndView();
		dynamicReportService.getQueryColumn(id);
		return mv;
	}
	
}
